<?php

use Illuminate\Database\Seeder;

class AdminRoleTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $developer = new \App\Models\Admin\Role();
        $developer->name = 'developer';
        $developer->display_name = '开发权限';
        $developer->description = '最大权限，仅供开发者使用';
        $developer->save();

        $administrator = new \App\Models\Admin\Role();
        $administrator->name = 'administrator';
        $administrator->display_name = '超管';
        $administrator->description = '超级管理员';
        $administrator->save();

        $list = \App\Models\Admin\Permission::get();
        foreach ($list as $key=>$value) {
            $developer->attachPermission($value);
            if ($value->is_developer == 0) {
                $administrator->attachPermission($value);
            }
        }
    }
}
